//
//  ChildCell.m
//  XMLY
//
//  Created by lanou on 15/11/4.
//  Copyright © 2015年 曾杰. All rights reserved.
//

#import "ChildCell.h"
#import "UIImageView+WebCache.h"
@interface ChildCell ()

@end


@implementation ChildCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 5, 100, 100)];
        [self.contentView addSubview:_myImageView];
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(115, 5, SCREEN_WIDTH - 150, 30)];
        _titleLabel.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:_titleLabel];
        
        self.descLabel = [[UILabel alloc] initWithFrame:CGRectMake(115, 40, SCREEN_WIDTH - 150, 30)];
        _descLabel.font = [UIFont systemFontOfSize:12];
        _descLabel.alpha = 0.6;
        [self.contentView addSubview:_descLabel];
        
        self.tingImageView = [[UIImageView alloc] initWithFrame:CGRectMake(115, 75, 20, 20)];
        _tingImageView.image = [UIImage imageNamed:@"erji"];
        [self.contentView addSubview:_tingImageView];
        
        self.tingCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(145, 75, 80, 30)];
        _tingCountLabel.font = [UIFont systemFontOfSize:12];
        _tingCountLabel.alpha = 0.6;
        [self.contentView addSubview:_tingCountLabel];
        
        self.tracksImageView = [[UIImageView alloc] initWithFrame:CGRectMake(225, 80, 20, 20)];
        _tracksImageView.image = [UIImage imageNamed:@"jishu"];
        [self.contentView addSubview:_tracksImageView];
        
        self.tracksLabel = [[UILabel alloc] initWithFrame:CGRectMake(245, 75, 100, 30)];
        _tracksLabel.font = [UIFont systemFontOfSize:12];
        _tracksLabel.alpha = 0.6;
        [self.contentView addSubview:_tracksLabel];
    }
    return self;
}

- (void)configureCellWithModel:(ChildDetailModel *)model{
    [self.myImageView sd_setImageWithURL:[NSURL URLWithString:model.albumCoverUrl290]];
    self.titleLabel.text = model.title;
    self.descLabel.text = model.intro;
    self.tracksLabel.text = [NSString stringWithFormat:@"%.0f集", model.tracks] ;
    if (model.playsCounts >= 10000 && model.playsCounts < 100000000) {
        self.tingCountLabel.text = [NSString stringWithFormat:@"%.1f万", model.playsCounts/ 10000] ;
    }else if (model.playsCounts >= 100000000){
        self.tingCountLabel.text = [NSString stringWithFormat:@"%.1f亿", model.playsCounts/ 100000000] ;
    }else{
        self.tingCountLabel.text = [NSString stringWithFormat:@"%f", model.playsCounts];
    }
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
